<template>
	<view style="width: 100%;height: 100%;background-color: #ECFDFA;">
		<view class="bj1">
			<span class="sj">购物车</span>
		</view>
		<view class="zong">
			<u-swipe-action @click="ddd(index)">
			        <u-swipe-action-item style="border-radius: 10px;" :name="item.scId" :options="options2" @click="sss" v-for="item in gwc">
			          <view class="swipe-action u-border-top u-border-bottom">
			            <view class="swipe-action__content">
			              <view class="sp" @click="spxq(item.commodityUnions.commodityId)">
			              	<view style="width: 100px;height: 100px;background-color: #000000;border-radius: 10px;margin-left: 20px;position: relative;top: 10px;display: inline-block">
			              		<image style="width: 100px;height: 100px;border-radius: 10px;" :src="item.commodityUnions.commodityimgs[0].pash"></image>
			              	</view>
			              	<view style="width: 200px;height: 30px;display: inline-block;margin-left:10px;position: relative;top: -10px;">
			              		<span style="color: #333333;font-size: 15px;">{{item.commodityUnions.commodityName}}</span>
			              		<br>
			              		<span style="color: #333333;font-size: 14px;margin-left: 160px;">{{item.commodityUnions.price}}币</span>
			              		<br>
			              		<span style="color: #333333;font-size: 15px;margin-left: 160px;">×{{item.sum}}</span>
			              		<br>
			              		<span style="color: #FE5E75;font-size: 15px;margin-left: 145px;"><b>{{item.price}}币</b></span>
			              	</view>
			              
			              </view>
			            </view>
			          </view>
			        </u-swipe-action-item>
			      </u-swipe-action>
		</view>
		 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				su:{},
				union:{
					commodity:{},
					sum:1,
					price:0,
					sptype:'',
					sptypeid:0,
				},
				userid:2,
				gwc:[],
				options2: [{
						text: '结算',
						style: {
							backgroundColor: '#3c9cff'
						}
					}, {
						text: '删除',
						style: {
							backgroundColor: '#f56c6c'
						}
					}],
			}
		},
		onLoad() {
			this.initgwc()
		},
		methods: {
			spxq(commodityid){
				uni.navigateTo({
					url:'./spxq?commodityid='+commodityid
				})
			},
			sss(res){
				console.log(res)
				if(res.index==0){
					uni.request({
						url:'http://localhost:9525/xkuser/ljp/gwcjs',
						method: 'GET',
					   data: {
						   scid: res.name,
					   },
					   dataType:'json',
					   success: (res) => {
							this.su=res.data.data.su
							this.union.commodity=this.su.commodityUnions
							this.union.sum=this.su.sum
							this.union.price=this.su.price
							this.union.sptype=this.su.selections.selectionName
							this.union.sptypeid=this.su.selectionId
							uni.navigateTo({
								url:'./djjs?union='+encodeURIComponent(JSON.stringify(this.union))
							})
							
						},
					})	
				}
				if(res.index==1){
					uni.request({
						url:'http://localhost:9525/xkuser/ljp/delgwc',
						method: 'GET',
					   data: {
						   scid: res.name,
					   },
					   dataType:'json',
					   success: (res) => {
							
							
						},
					})	
				}
				
			},
			initgwc(){
				uni.request({
					url:'http://localhost:9525/xkuser/ljp/initgwc',
					method: 'GET',
				   data: {
					   userid: this.userid,
				   },
				   dataType:'json',
				   success: (res) => {
						this.gwc=res.data.data.gwc
					},
				})	
			}
		}
	}
</script>

<style>
	.sp{
		width: 334px;
		height: 120px;
		background-color: #FFFFFF;
		border-radius: 10px;
	}
	.zong{
		width: 334px;
		height: 500px;
		margin-left: 20px;
		margin-top: -130px;
	}
	.sj{
		font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
		    font-weight: 700;
		    font-size: 20px;
		    color: #FFFFFF;
		    margin-left: 15px;
			position: absolute;
			top: 20px;
	}
	.bj1{
			width:100%;
			height:468rpx;
			background-image: url(../../static/indeimg/xia.png);
			
		}
	.u-page {
	        padding: 0;
	    }
	
	    .u-demo-block__title {
	        padding: 10px 0 2px 15px;
	    }
	
	    .swipe-action {
	        &__content {
	             padding: 25rpx 0;
	    
	            &__text {
	                 font-size: 15px;
	                 color: $u-main-color;
	                 padding-left: 30rpx;
	             }
	        }
				}
</style>
